<div class="tableinfo">
    <div class="tableHeader">
        <p>Đề Án đã tham gia</p>
    </div>
    
    
    <table border ="0" cellspacing ="0" cellpadding ="0">
        
        <tr style="background: silver; font-weight: bold;">
         
            <td>Mã đề án</td>
            <td>Tên Đề Án</td>
            <td>Địa Điểm Đề Án</td>

                
        </tr>
         
            
                <?php
                    $idnv = $_SESSION["userlogin"];
                    
                    //so dong hien thi tren mot trang
                            $hienthi = 10;
                            //tinh tong so trang
                            if(isset($_GET['page']) && (int)$_GET['page']){
                                $page = $_GET['page'];
                            }else{
                                $sodong = "select id_NhanVien from phancong where id_NhanVien='$idnv'";
                                $kq=executeQuery($sodong);
                                $kq_sodong =mysql_num_rows($kq);
                                $so = $kq_sodong;
                                if($so>$hienthi){
                                    $page = ceil($so/$hienthi);
                                }else{
                                    $page = 1;
                                }
                            }
                            //vitri bat dau hien thi
                            $vitri = (isset($_GET['vitri'])&& (int)$_GET['vitri']) ? $_GET['vitri']:0;
        
                            
                    
                    $load_ds_dean = "select a.MaDA,b.TenDA,b.DDiemDA from phancong a inner join dean b on a.MaDA = b.MaDA where id_NhanVien='$idnv' limit $vitri, $hienthi";
                    $kq_load_ds_dean = executeQuery($load_ds_dean);
                    while($ds = mysql_fetch_array($kq_load_ds_dean)){
                        $tendan = $ds['TenDA'];
                        $mada = $ds['MaDA'];
                        $diadiem = $ds['DDiemDA'];
                        echo "<tr><td> $mada</td> <td>$tendan</td> <td>$diadiem</td></tr>";
                    }
                 ?>
            
            

     
             

    </table>
            <ul class="phantrang">
            <?php
            if($_SESSION['vaitro']=="Quản Trị"){
                $url="../admin/dsdeanthamgia.php?vitri=";
            }else{
               $url="../view/dsdeanthamgia.php?vitri="; 
            }
            
            //xuất hiện số trang
              if($page >1){
                $sau = $vitri + $hienthi;
                $truoc = $vitri - $hienthi;
                $tranght= ($vitri/$hienthi)+1;

                //nut pre                
                if($tranght !=1){
                    echo "<li><a href='$url".$truoc."'>Trước</a></li>";
                }
                
                //so trang
                for($i=1; $i<=$page; $i++ ){
                    if($tranght != $i){
                        echo "<li><a href='$url".$hienthi*($i-1)."'>$i</a></li>"; 
                    }else{
                        echo "<li class='hientai'><a href=''>$i</a></li>";
                    } 
                }
                
                
                //nut next
                if($tranght != $page){
                    echo "<li><a href='$url".$sau."'>Sau</a></li>";
                }
              }  
            ?>
             
        </ul>    
    
</div>
